module.exports = {
  /*
  ** Headers of the page
  */
  head: {
    title: '卢忠宽的博客',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      {
        name: 'keywords',
        content:
          '卢忠宽,个人博客,前端开发,html,css,js,react,vue,nuxt,小程序,微信公众号开发,node,mysql,php,linux,nginx'
      },
      {
        hid: 'description',
        name: 'description',
        content:
          '卢忠宽的个人博客，一个安静的前端开发工程师，希望在随手记录中提升自己，实现技术全栈，达到人生巅峰'
      }
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
    script: [
      {
        src: '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js',
        async: true
      },
      {
        src: 'https://hm.baidu.com/hm.js?4dc655ed71352ec8dc3a35a2e9d29283'
      } /*引入百度统计的js*/
    ]
  },
  sourceMap: false,
  transition: 'fadeIn',
  plugins: [{ src: '~plugins' }, { src: '~plugins/du.js', ssr: false }],
  css: [
    '~assets/style/reset.css',
    { src: '~assets/style/main.scss', lang: 'scss' }
  ],
  /*
  ** Customize the progress bar color
  */
  loading: { color: '#3B8070' },
  router: {
    middleware: 'userAgent',
    // router: {
    //   scrollBehavior: function (to, from, savedPosition) {
    //     return savedPosition || { x: 0, y: 0 }
    //   }
    // }
  },
  resourceHints: false,
  render: {
    bundleRenderer: {
      shouldPreload: (file, type) => {
        return ['script', 'style', 'font'].includes(type)
      },
      cache: require('lru-cache')({
        max: 1000,
        maxAge: 1000 * 60 * 15
      })
    }
  },
  /*
  ** Build configuration
  */
  build: {
    publicPath: '',
    vendor: ['axios', 'moment'],
    postcss: [
      require('postcss-nested')(),
      require('postcss-responsive-type')(),
      require('postcss-hexrgba')()
    ],
    extractCSS: {
      allChunks: true
    },
    /*
    ** Run ESLint on save
    */
    extend(config, { isDev, isClient }) {
      if (isDev && isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
      const vueLoader = config.module.rules.find(
        rule => rule.loader === 'vue-loader'
      )
      vueLoader.options.loaders.sass = 'vue-style-loader!css-loader!sass-loader'
    }
  }
}
